package com.tanhua.model.vo;

import com.tanhua.model.mongo.Question;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.List;

/**
 * 返回问题vo类
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class QuestionVo implements Serializable {
    private String id; //试题id
    private String questionnaireId; //所属问卷id
    private String question; //题目
    private List<OptionVo> options;   //选项

    public static QuestionVo init(Question question){
        QuestionVo vo = new QuestionVo();
        BeanUtils.copyProperties(question, vo);
        vo.setId(question.getId().toHexString());
        vo.setQuestionnaireId(question.getQuestionnaireId().toHexString());
        return vo;
    }
}
